package com.shihb.behavioralpatterns.iteratorpattern;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 *Description:
 *Version:1.0.0
 *@author shihb
 *@date 2020/7/28 19:36
 */
public class ComputerAggregation implements CollegeAggregation {
  private List departments;
  private String name;

  public ComputerAggregation() {
    name="计算机学院";
    departments=new ArrayList<Department>();
    setElement(new Department("JAVA系"));
    setElement(new Department("大数据系"));
    setElement(new Department("WEB系"));
  }


  @Override
  public Iterator create() {
    return new ComputerIterator(departments);
  }

  @Override
  public void setElement(Department department) {
    departments.add(department);
  }

  @Override
  public String getName() {
    return name;
  }
}
